import Vue from "vue"

import VueRouter from "vue-router"

Vue.use(VueRouter)

const Home = () => import("@pages/Home")
const Login = () => import("@pages/Login")
const Search = () => import("@pages/Search")
const Register = () => import("@pages/Register")
const Detail = () => import("@pages/Detail")

const last = VueRouter.prototype.push

VueRouter.prototype.push = function (location, onComplete = () => {}, onAbort = () => {}) {
    last.call(this, location, onComplete, onAbort)
}

export default new VueRouter({
    mode: "history",
    routes: [{
            path: "/home",
            component: Home,
            name: 'home'
        },
        {
            path: "/login",
            component: Login,
            name: 'login',
            meta: {isShow:true}
        },
        {
            path: "/search/:keyword?",
            component: Search,
            name: 'search'

        },
        {
            path: "/register",
            component: Register,
            name: 'register',
            meta: {isShow:true}
        },
        {
            path: "/detail",
            component: Detail,
            name: 'detail'

        },
        {
            path: "/",
            redirect:"/home"
        },
    ]
})